ReplaceB Function
Replaces the first occurrence of a String with another String.
Syntax
result = ReplaceB( sourceString, oldString, newString )
result = stringVariable.ReplaceB( oldString, newString )
Parameters | ||
sourceString |
The original string. |
|
oldString |
The characters to be replaced. |
|
newString |
The replacement characters. |
Notes
Replaces the first occurrence of oldString in sourceString with newString. ReplaceB is the binary version of Replace.
If newString is an empty string (""), the ReplaceB function deletes the first occurrence of the oldString in the sourceString.
If oldString is an empty string (""), the ReplaceB function returns an unchanged copy of the sourceString.
ReplaceB is case-sensitive; it treats sourceString as a series of raw bytes. It should be used instead of Replace when the string represents binary data or when your application will run in a one-byte character set (such as the US system) and you want case-sensitivity.
Examples
Below are some examples that show the results of the ReplaceB function:
result=ReplaceB ("The quick fox","fox","rabbit") //returns "The quick rabbit"
result=ReplaceB("The quick fox","f","b") //returns "The quick box"
result=ReplaceB("The quick fox","quick","") //returns "The fox"
Using the second syntax:
s="The quick fox"
result=s.ReplaceB ("fox","rabbit") //returns "The quick rabbit"
MsgBox result
See Also
ReplaceAll, ReplaceAllB, Replace, ReplaceLineEndings functions.